package org.liang.code.utils;

import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MybatisUtils {

    private static final SqlSessionFactory sqlSessionFactory;

    static {
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(MybatisUtils.class.getClassLoader().getResourceAsStream("mybatis-config.xml"));
    }

    public static SqlSession openSession(Boolean autoCommit) {
        return sqlSessionFactory.openSession(autoCommit);
    }

    public static SqlSession openSession(ExecutorType type, Boolean autoCommit) {
        return sqlSessionFactory.openSession(autoCommit);
    }
}
